package dujiu.leetcode.slidingWindow.fixed_lengthSlidingWindow;

public class P1343 {
    public int numOfSubarrays(int[] arr, int k, int threshold) {
        int sum = 0;// 窗口元素的和
        int count = 0; // 子数目的个数
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
            if (i < k-1){
                continue;
            }
            if (sum/k >= threshold){
                count++;
            }
            sum -= arr[i-k+1];
        }
        return count;
    }

    public static void main(String[] args) {
        int[] arr = {2,2,2,2,5,5,5,8};
        P1343 p = new P1343();
        System.out.println(p.numOfSubarrays(arr, 3, 4));
    }
}
